var app = getApp();
Page({
  data: {
    remark: true,
    disble: false,
    btnname: "确认提交",
    AreaName: '',
    AreaId: '',
    items: [],
    Temp: true,
    date: '2020-01-01',
    fdate: '2020-06-13',
    scrollTop: 0,
    FullName: '',
    ctypeid: '',
    mydata:{id:'',FullName:''}
  },
  onLoad: function () {
    //this.getitem();  
  },
  onShow: function () {
    var pages = getCurrentPages();
    var currPage = pages[pages.length - 1]; //当前页面
    let json = currPage.data.mydata;
    this.data.FullName = currPage.data.mydata.FullName;
    this.data.ctypeid = currPage.data.mydata.id;
    console.log(json)//为传过来的值
  },
  onPageScroll: function (e) {
    this.setData({
      scrollTop: e.scrollTop
    })
  },
  bindDateChange: function (e) {
    this.setData({
      date: e.detail.value
    })

  },
  bindfDateChange: function (e) {
    this.setData({
      fdate: e.detail.value
    })
  },

  goto_ManagerCus: function () {
    wx.navigateTo({
      url: "K_ManagerCus"
    })
  },
  clear_mydata: function () {    
    this.setData({
      FullName: '',ctypeid:'',mydata:{id:'',FullName:''}
    })    
  },
  getDate: function () {
    var that = this;
    wx.cloud.callFunction({
      name: 'GetPost',
      data: {
        data: "fun=7&QueryStr=" + that.data.date + "&QueryStr1=" + that.data.fdate + "&QueryStr2="+that.data.mydata.id        
      },
      success: res => {
        console.log(res);
        let obj = JSON.parse(res.result)
        that.setData({ list: obj })
      },
      fail: err => {
        wx.showToast({
          icon: 'none',
          title: '调用失败',
        })
      }
    })
  },
  wselect(e) {
    var that = this;
    var Index = e.detail.value;
    console.log(Index);
    this.setData({
      AreaName: that.data.items[Index].FullName,
      AreaId: that.data.items[Index].typeId
    })
  },
  submitForm: function () {
    var fdate = this.data.fdate;
    var date = this.data.date,that=this;
    if (fdate.substring(1, 4) != date.substring(1, 4)) {
      wx.showModal({
        title: '提示',
        content: '不支持跨年查询~',
        showCancel: false
      })
      return false;
    };
    this.setData({ Temp: false, remark: false });
    this.getDate();
  },
  showit: function () {
    this.setData({ remark: true });
  }
})